

import { Context } from "../class/Context";
import { Debuff } from "../class/Effect";
import { Hurt } from "../class/Hurt";
import { Method } from "../class/Method";

/**
 * 八段摔
 */
export class BaDuanShuai extends Method {
    static methodName = "八段摔"
    public CD: number = 30E3;
    public describe: string = "在八秒内把敌人连摔八次，每次造成 70%(MA) 法术伤害,并在最后一摔附加 10(lossHP) 真实伤害。";
    invoke(context: Context): void {
        const itid = context.nextParam();
        const it = this.masterRole.game.getRole(itid);
        const masterRole = this.masterRole;

        
        //  给目标添加一个负面效果。共 8 秒，每次间隔 1 秒
        it.addEffectByClass(class extends Debuff {
            public sumTime: number = 8E3;
            public eachTime: number = 1E3;
            // 当前次数
            public index: number = 0;
            public invoke(): void {
                // 每摔一次，次数加一
                this.index += 1;
                const MA = Math.floor(this.masterRole.getMagicAttack() * 0.7);// 计算伤害
                // 前面七下
                if (this.index <= 7) {
                    this.masterRole.onHurt(masterRole, new Hurt(0, MA, 0))
                } else { // 第八下
                    // 计算真实伤害
                    const TD = Math.floor(this.masterRole.getLossHP() * 0.1);
                    this.masterRole.onHurt(masterRole, new Hurt(0, MA, TD))
                }
            }

        })
    }
}